package advance_2;
import java.util.*;
public class CalTest {
    public static void main(String[] args) {
        //常量,分区你要哪一个
        Calendar c=Calendar.getInstance();//找一个合适的子类
        System.out.println(c.getClass().getName());
        System.out.println("DAte:"+c.getTime());
        System.out.println("毫秒:"+c.getTimeInMillis());
        System.out.println(c);
        //年月日
        int year=c.get(Calendar.YEAR);
        System.out.println("年:"+year);
        System.out.println("月:"+c.get(Calendar.MONTH));
        System.out.println("天:"+c.get(Calendar.DAY_OF_MONTH));
        int days=c.get(Calendar.DAY_OF_YEAR);
        System.out.println("今天是今年的等几天:"+days);
        System.out.println("今天第几周? "+c.get(Calendar.WEEK_OF_YEAR));
        System.out.println(">>>>>>");
//        c.add(Calendar.DATE,50);
        c.roll(Calendar.DATE,50);//不涨上一级
        System.out.println("50天后:"+c.getTime());
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>.");
        int yearday=c.getActualMaximum(Calendar.DAY_OF_YEAR);
        System.out.println("days="+yearday);

        //直接设置日期
        c.set(Calendar.YEAR,2021);
        c.set(Calendar.MONTH,Calendar.JUNE);
        c.set(Calendar.DAY_OF_MONTH,126);
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>.");
        System.out.println("date:"+c.getTime());
    }
}
